<template>
<div>
  <v-card
    :loading="loading"
    class="mx-auto my-12"
    max-width="374"
  >
    <v-card-title>{{ from.title }}</v-card-title>
    <v-card-text>
      <div class="my-4 subtitle-1 black--text" v-show="false">
        {{ from.title }}
      </div>
      <div>{{ from.desc }}</div>
    </v-card-text>
    <v-divider class="mx-4"></v-divider>
    <v-card
      elevation="0"
      max-width="444"
      class="mx-auto"
     
    >
    <v-system-bar lights-out></v-system-bar>
    <v-carousel
      :continuous="false"
      :show-arrows="false"
      hide-delimiter-background
      delimiter-icon="mdi-minus"
      height="300"
      v-if="fromimages != '' "
    >
    <v-carousel-item
        v-for="(image, i) in fromimages"
        :key="i"
      >
          <v-row
            class="fill-height"
            align="center"
            justify="center"
          >
            <v-img :src="image"></v-img>
          </v-row>
      </v-carousel-item>
    </v-carousel>
    <v-list two-line>
      <v-list-item>
        <v-list-item-avatar v-show="false">
          <v-img ></v-img>
        </v-list-item-avatar>
        <v-list-item-content>
          <v-list-item-title> 姓名：{{ from.name }}</v-list-item-title>
          <v-list-item-subtitle> 联系信息：{{ from.contact }}</v-list-item-subtitle>
          <v-list-item-subtitle> 联系时间：{{ from.time }}</v-list-item-subtitle>
        </v-list-item-content>
        <v-list-item-action>
          <v-btn @click="playAudio(from.audio)" v-if="from.audio != ''"> 播放录音 </v-btn>
        </v-list-item-action>
      </v-list-item>
    </v-list>
  </v-card>
    <v-card-text>
      <div class="text--primary"></div>
      <v-chip-group
        active-class="deep-purple accent-4 white--text"
        column
      >
      </v-chip-group>
    </v-card-text>
  </v-card>
</div>
</template>

<script>
import { GetUnderwriterFromInfo,URLP, orderstatus } from './../../api/api'
  export default {
    data: () => ({
        loading: true,
        selection: 1,
        e6: 1,
        from:{
            title:'',
            desc:'',
            audio:'',
            images:'',
            name:'',
            contact:'',
            time:'',
        },
        fromimages:''
    }),

    methods: {
      playAudio:function(audioSRC){
        let audio = new Audio()
          audio.src = audioSRC
          audio.play();
      },
      reserve: function() {
        
        // setTimeout(() => (this.loading = false), 2000)
      },
    },
    created: function(){

        let order_no = URLP("order_no")
        if(order_no){ // 存在订单可以进行提交
            GetUnderwriterFromInfo(order_no,this.$cookies.get("authtoken"))
            .then((resp)=>{
            this.$store.commit('setProgress',false)
                    var res = resp.data
                    if(res.code == 1){
                        this.from.name = res.data.name
                        this.from.contact = res.data.contact
                        this.from.time = res.data.time_slot
                        this.from.title = res.data.title
                        this.from.desc = res.data.desc
                        this.from.audio = res.data.audio
                        this.fromimages = res.data.images.split(",")
                        console.log(this.fromimages)
                    }else{
                        alert(res.msg)
                        // window.location.href = "/underwriter/create/order"
                    }
                    this.loading = false
                })
            .catch(()=>{
              this.loading = false
                alert("网络错误")
            })
        }else{
          this.loading = false
          alert("非法访问")  
        }
    }
  }
</script>